import * as api from '../mutation-types'

const state = {
  personalInfo: {}, // 存储个人登陆信息
  showLoginWindow: false // 是否显示登陆窗口，true显示
}

// getters
const getters = {
  [api.GET_PERSONAL_INFO]: state => state.personalInfo,
  [api.IS_SHOW_LOGIN_WINDOW]: state => state.showLoginWindow
}

// mutations
const mutations = {
  [api.IS_SHOW_LOGIN_WINDOW] (state, isShow) { // 设置是否显示登陆窗口，true显示
    state.showLoginWindow = isShow
  },
  [api.SET_PERSONAL_INFO] (state, param) { // 设置用户信息
    state.personalInfo = param
  }
}

// actions
const actions = {
  [api.SET_PERSONAL_INFO] ({commit}, param) {
    commit(api.SET_PERSONAL_INFO, param)
  },
  [api.IS_SHOW_LOGIN_WINDOW] ({commit}, isShow) {
    commit(api.IS_SHOW_LOGIN_WINDOW, isShow)
  }
}

export default {
  state,
  getters,
  mutations,
  actions
}
